package com.campus.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.campus.mapper.MajorMapper;
import com.campus.pojo.po.Major;
import com.campus.pojo.vo.MajorVO;
import com.campus.service.MajorService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MajorServiceImpl implements MajorService {
    private final MajorMapper majorMapper;
    /**
     * 通过院系id查询专业信息
     * @param id
     * @return
     */
    @Override
    public List<MajorVO> getMajorByFacultyId(Integer id) {
        List<Major> majors = majorMapper.getMajorByFacultyId(id);
        return BeanUtil.copyToList(majors, MajorVO.class);
    }

    @Override
    public List<MajorVO> getMajorAll() {
        List<Major> majors = majorMapper.getMajorAll();
        return BeanUtil.copyToList(majors, MajorVO.class);
    }
}
